package br.com.consigsys.model.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * The persistent class for the tcons_uf database table.
 * 
 */
@Entity
@Table(name="tcons_uf")
public class TconsUf extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID_UF", updatable=false, unique=true, nullable=false)
	private Integer idUf;

    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="DATA_ULT_ALTERACAO")
	private Date dataUltAlteracao;

	@Column(name="NOME_UF", length=40)
	private String nomeUf;

	@Column(name="SIGLA_UF", length=2)
	private String siglaUf;

	@Column(name="USUARIO_ULT_ALTERACAO", length=150)
	private String usuarioUltAlteracao;

	@Column(name="VERSAO")
	private Integer versao;
	
	@OneToMany(mappedBy = "uf")
	private Set<TconsConsignataria> consignataria;

    public TconsUf() {
    }

    @PrePersist
    protected void beforePersist(){
    	this.versao = 1;
    	this.dataUltAlteracao = new Date();
    	
    }

    @PreUpdate
    protected void beforeUpdate(){
    	this.dataUltAlteracao = new Date();
    	
    }
    
    
	public Integer getIdUf() {
		return this.idUf;
	}

	public void setIdUf(Integer idUf) {
		this.idUf = idUf;
	}

	public Date getDataUltAlteracao() {
		return this.dataUltAlteracao;
	}

	public void setDataUltAlteracao(Date dataUltAlteracao) {
		this.dataUltAlteracao = dataUltAlteracao;
	}

	public String getNomeUf() {
		return this.nomeUf;
	}

	public void setNomeUf(String nomeUf) {
		this.nomeUf = nomeUf;
	}

	public String getSiglaUf() {
		return this.siglaUf;
	}

	public void setSiglaUf(String siglaUf) {
		this.siglaUf = siglaUf;
	}

	public String getUsuarioUltAlteracao() {
		return this.usuarioUltAlteracao;
	}

	public void setUsuarioUltAlteracao(String usuarioUltAlteracao) {
		this.usuarioUltAlteracao = usuarioUltAlteracao;
	}

	public Integer getVersao() {
		return this.versao;
	}

	public void setVersao(Integer versao) {
		this.versao = versao;
	}
	
	@Override
	public Integer getId() {
		return this.getIdUf();
	}

	@Override
	public void setId(Integer id) {
		this.setIdUf(id);
		
	}

	public Set<TconsConsignataria> getConsignataria() {
		return consignataria;
	}

	public void setConsignataria(Set<TconsConsignataria> consignataria) {
		this.consignataria = consignataria;
	}

}